package com.minhang.controller;

import com.minhang.utils.encryption.RSAUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author rookie
 */
@RestController
@Slf4j
public class GetKey {


    @Resource(name = "rsaKeyPair")
    private Map<String, Object> map;

    /**
     * 获取公钥接口
     *
     * @return
     */
    @PostMapping("/publicKey")
    public String getPublicKey() throws Exception {
        //获取公钥
        String publicKey = RSAUtil.getPublicKey(map);
        return publicKey;
    }

    /**
     * 获取私钥
     *
     * @return
     * @throws Exception
     */
    @PostMapping("/privateKey")
    public String privateKey() throws Exception {
        //获取私钥钥
        String privateKey = RSAUtil.getPrivateKey(map);
        return privateKey;
    }


}
